﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Documents;
	using System.Windows;
	using System.Windows.Media;
using System.Windows.Controls;

namespace WpfClient
{
    public class AdornerContainer : Adorner
    {
        private UIElement child;

        public AdornerContainer(UIElement adornedElement)
            : base(adornedElement)
        {
        }

        protected override Size ArrangeOverride(Size finalSize)
        {
            if (this.child != null)
                this.child.Arrange(new Rect(finalSize));
            return finalSize;
        }

        public UIElement Child
        {
            get { return this.child; }
            set
            {
                this.AddVisualChild(value);
                this.child = value;
            }
        }

        protected override int VisualChildrenCount
        {
            get { return this.child == null ? 0 : 1; }
        }

        protected override Visual GetVisualChild(int index)
        {
            if (index == 0 && this.child != null)
                return this.child;
            return base.GetVisualChild(index);
        }
    }
}
